import { reactive, toRefs } from 'vue'

import { codeMaps, getByDictCodeList } from '@/api/backend/dict'
import { getToday } from '@/api/help'

import IBaseObj from '#/index'

const commonState: IBaseObj = reactive({
  passOptions: [
    {
      label: '不符合',
      value: false,
    },
    {
      label: '符合',
      value: true,
    },
  ],
  priorityOptions: [],
})

const getDictData = async () => {
  const ret = await getByDictCodeList([codeMaps.priority])
  commonState.priorityOptions = ret[codeMaps.priority]
}

const getTodayTime = async () => {
  const ret = await getToday()
  return ret.data
}

export default {
  ...toRefs(commonState),
  getDictData,
  getTodayTime,
} as IBaseObj
